package com.itheima.reggie.mapper;

import com.itheima.reggie.dto.DishDto;
import com.itheima.reggie.entity.Dish;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.Param;

import java.time.LocalDateTime;
import java.util.List;

@Mapper
public interface DishMapper {
    @Select("select count(*) from dish where category_id=#{id};")
    Long findById(Long id) ;

    List<Dish> findByName(@Param("page") Integer page, @Param("pageSize") Integer pageSize, @Param("name") String name);
    @Insert("insert into dish values(null,#{name},#{categoryId},#{price},#{code},#{image},#{description},#{status},#{sort},#{createTime},#{updateTime},#{createUser},#{updateUser},0);")
    @Options(useGeneratedKeys = true,keyColumn = "id",keyProperty = "id")
    void saveWithFlavors(DishDto dishDto);
    @Select("select *from dish where id=#{id}")
    Dish selectById(Long id);

    void update(DishDto dishDto);
//    @Select("select *from dish where category_id=#{categoryId} and status=#{status};")
    List<Dish> findByIdlist(@Param("categoryId") Long categoryId, @Param("status") Integer status);

    Long queryStatusBatch(@Param("ids") List<Long> ids);

    void deleteByIds(@Param("ids") List<Long> ids);

    void updateStatusZero(List<Long> ids, Long empId, LocalDateTime updateTime);

    void updateStatusOne(List<Long> ids, Long empId, LocalDateTime updateTime);
}

